<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>login</title>
    <@header/>
</head>
<body class="login-bg">

<div class="login">
    <div class="message">oss</div>
    <div id="darkbannerwrap">
    </div>

    <form method="post" class="layui-form"   >
        <input name="username" placeholder="用户名" type="text" lay-verify="required" class="layui-input">
        <hr class="hr15">
        <input name="password" lay-verify="required" placeholder="密码" type="password" class="layui-input">
        <hr class="hr15">
        <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
        <hr class="hr20">
        <p class="layui-bg-red" style=" text-align: center;display: none" id="msg" >账号或密码错误</p>
    </form>
</div>

<script>
    $(function () {
        layui.use('form', function () {
            var form = layui.form;
            //监听提交
            form.on('submit(login)', function (data) {
                console.log(data.field);
                var field=data.field;
                $.post('<@path/>/login',field,function(result){
                   if(result.meta.success)
                   { window.location.href="<@path/>/index";}
                   else{
                       $("#msg").show();
                   }
                });

                return false;
            });
        });
    })
</script>
</body>
</html>